package com.zhxt.web.controller.reportapi;

import com.zhxt.common.annotation.Log;
import com.zhxt.common.core.domain.AjaxResult;
import com.zhxt.common.core.text.Convert;
import com.zhxt.common.enums.BusinessType;
import com.zhxt.common.utils.StringUtils;
import com.zhxt.system.domain.SysTjcode;
import com.zhxt.system.domain.ZhxtItemsStep;
import com.zhxt.system.domain.zhxtvo.*;
import com.zhxt.system.service.IHxwhService;
import com.zhxt.system.service.ILeaderSerivce;
import com.zhxt.system.service.IZhxtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;


/**
 * 指挥系统-大屏
 *
 * @author zhxt
 */

@RestController
@RequestMapping("/repapi/zhxt")
public class ZhxtController {

    @Autowired
    private IZhxtService iZhxtService;

    @Autowired
    private ILeaderSerivce iLeaderSerivce;

    @Autowired
    private IHxwhService iHxwhService;
    /**
     * 获取数据最后一次更新时间
     */
    @GetMapping("getLastTime")
    public AjaxResult getLastTime(){
        AjaxResult ajax=AjaxResult.success();
        String utime=iZhxtService.getLastTime();
        ajax.put("lasttime",utime);
        return ajax;
    }

    /**
     * 机构总览报表数据
     */
    @Log(title = "大屏-查看整体报表", businessType = BusinessType.OTHER)
    @PostMapping("/getZlReport")
    public AjaxResult getZlReport(){
        AjaxResult ajax = AjaxResult.success();
        String utime=iZhxtService.getLastTime();
        String dateStr="";
        if(StringUtils.isNotEmpty(utime)){
            dateStr=utime.substring(0,10);
        }

        //获取报表一级数据
        List<ZhxtZItems> zhxtZItemsList=iZhxtService.getZhxtYItems("1001",dateStr);
        if(zhxtZItemsList!=null && !zhxtZItemsList.isEmpty()){
            ajax.put("zbitems",zhxtZItemsList);
        }

        //排名
        List<ZhxtZTj> zhxtZTjList=iZhxtService.getZhxtZTj("1001",dateStr);
        if(zhxtZTjList!=null && !zhxtZTjList.isEmpty()){
            ajax.put("zbpm",zhxtZTjList);
        }

        //获取各机构二级数据
        //List<SysTjcode> sysTjcodeList = iLeaderSerivce.getTjcodeZzList();
        List<ZhxtZzData> zhxtZzDataList=new ArrayList<>();
        for (ZhxtZTj sysTjcode : zhxtZTjList) {
            ZhxtZzData zhxtZzData=new ZhxtZzData();
            zhxtZzData.setTjcode(sysTjcode.getTjcode());
            zhxtZzData.setTjname(sysTjcode.getTjname());
            //zhxtZzData.setUptjcode(sysTjcode.getUptjcode());
            zhxtZzData.setZhxtZItemsList(iZhxtService.getZhxtZzItems("1001",dateStr,sysTjcode.getTjcode()));
            zhxtZzDataList.add(zhxtZzData);
        }
        ajax.put("zzdata",zhxtZzDataList);
        //象限图数据
        List<ZhxtXxt> zhxtXxtListX=iZhxtService.getTListOne("1001",dateStr,"202301101034049");
        List<ZhxtXxt> zhxtXxtListY=iZhxtService.getTListZlgc("1001",dateStr);
        //double avgIntx=zhxtXxtListX.stream().collect(Collectors.averagingDouble(ZhxtXxt::getIntx));
        double avgIntx=40;
        //double avgInty=zhxtXxtListY.stream().collect(Collectors.averagingDouble(ZhxtXxt::getInty));
        double avgInty=1.1;
        if(zhxtXxtListX!=null && zhxtXxtListY !=null){
            for (ZhxtXxt zhxtXxtx:zhxtXxtListX){
                for (ZhxtXxt zhxtXxty:zhxtXxtListY){
                    if(zhxtXxtx.getTjcode().equals(zhxtXxty.getTjcode())){
                        zhxtXxtx.setInty(zhxtXxty.getInty());
                        break;
                    }
                }
            }
        }

        ZhxtXxt zhxtXxtn=new ZhxtXxt();
        zhxtXxtn.setTjcode("00");
        zhxtXxtn.setTjname("原点");
        zhxtXxtn.setIntx(avgIntx);
        zhxtXxtn.setInty(avgInty);
        zhxtXxtListX.add(zhxtXxtn);
        ajax.put("xxt",zhxtXxtListX);
        return ajax;
    }

    /**
     * 机构总览报表数据二级明细
     */
    @Log(title = "大屏-查看整体报表明细", businessType = BusinessType.OTHER)
    @PostMapping("/getZlReportMx")
    public AjaxResult getZlReportMx(String tjcode){
        AjaxResult ajax = AjaxResult.success();
        if(StringUtils.isNotEmpty(tjcode)){
            iHxwhService.updateItemValue();
            String utime = iZhxtService.getLastTime();
            String dateStr = "";
            if(StringUtils.isNotEmpty(utime)){
                dateStr = utime.substring(0, 10);
            }
            List<ZhxtZItems> zhxtZItemsList=iZhxtService.getMItemsList("1001",dateStr,tjcode);
            ajax.put("data",zhxtZItemsList==null?new ArrayList<>():zhxtZItemsList);
            SysTjcode sysTjcode=iLeaderSerivce.getTjName(tjcode);
            ajax.put("tjname",sysTjcode==null?"":sysTjcode.getTjname());
        }
        return ajax;
    }
    /**
     * 获取经营报表数据
     */
    @Log(title = "大屏-查看经营报表", businessType = BusinessType.OTHER)
    @PostMapping("/getJyReport")
    public AjaxResult getJyReport(){
        AjaxResult ajax = AjaxResult.success();
        String utime=iZhxtService.getLastTime();
        String dateStr = "";
        if(StringUtils.isNotEmpty(utime)){
            dateStr = utime.substring(0, 10);
        }
        //获取报表一级数据
        List<ZhxtZItems> zhxtZItemsList=iZhxtService.getZhxtYItems("1002",dateStr);
        ajax.put("zbitems",zhxtZItemsList==null?new ArrayList<ZhxtZItems>():zhxtZItemsList);

        //获取经营指标数据
        //排名
        List<ZhxtZTj> zhxtZTjList=iZhxtService.getZhxtZTj("1002",dateStr);
        ajax.put("zbpm",zhxtZTjList==null?new ArrayList<ZhxtZTj>():zhxtZTjList);
        //获取二级数据
        //List<SysTjcode> sysTjcodeList = iLeaderSerivce.getTjcodeZzList();
        List<ZhxtZzData> zhxtZzDataList=new ArrayList<>();
        if(zhxtZTjList != null){
            for (ZhxtZTj sysTjcode : zhxtZTjList) {
                ZhxtZzData zhxtZzData=new ZhxtZzData();
                zhxtZzData.setTjcode(sysTjcode.getTjcode());
                zhxtZzData.setTjname(sysTjcode.getTjname());
                //zhxtZzData.setUptjcode(sysTjcode.getUptjcode());
                zhxtZzData.setZhxtZItemsList(iZhxtService.getZhxtZzItems("1002",dateStr,sysTjcode.getTjcode()));
                zhxtZzDataList.add(zhxtZzData);
            }
        }
        ajax.put("zzdata",zhxtZzDataList);

        //List<ZhxtZItems> zhxtZItemsListAvg=iZhxtService.getAvgItems("1002",dateStr);
        //ajax.put("avgdata",zhxtZItemsListAvg);

        //获取预警指标
        List<ZhxtYjData> zhxtYjDataList=iZhxtService.getTListyj("1002",dateStr);
        ajax.put("yjdata",zhxtYjDataList==null?new ArrayList<ZhxtYjData>():zhxtYjDataList);
        return ajax;
    }

    /**
     * 获取经营报表明细数据
     */
    @Log(title = "大屏-查看经营报表明细", businessType = BusinessType.OTHER)
    @PostMapping("/getJyReportMx")
    public AjaxResult getJyReportMx(String tjcode) {
        AjaxResult ajax = AjaxResult.success();
        String utime = iZhxtService.getLastTime();
        String dateStr = "";
        if(StringUtils.isNotEmpty(utime)){
            dateStr = utime.substring(0, 10);
        }
        List<ZhxtZItems> zhxtZItemsList=iZhxtService.getMItemsList("1002",dateStr,tjcode);
        ajax.put("data",zhxtZItemsList);
        SysTjcode sysTjcode=iLeaderSerivce.getTjName(tjcode);
        ajax.put("tjname",sysTjcode==null?"":sysTjcode.getTjname());
        return ajax;
    }

    /**
     * 获取管理报表数据
     */
    @Log(title = "大屏-查看健康管理报表", businessType = BusinessType.OTHER)
    @PostMapping("/getGlReport")
    public AjaxResult getGlReport(){
        AjaxResult ajax = AjaxResult.success();
        String utime=iZhxtService.getLastTime();
        String dateStr = "";
        if(StringUtils.isNotEmpty(utime)){
            dateStr = utime.substring(0, 10);
        }
        //获取报表一级数据
        List<ZhxtZItems> zhxtZItemsList=iZhxtService.getZhxtYItems("1003",dateStr);
        ajax.put("zbitems",zhxtZItemsList==null?new ArrayList<ZhxtZItems>():zhxtZItemsList);

        //获取管理指标数据
        //排名
        List<ZhxtZTj> zhxtZTjList=iZhxtService.getZhxtZTj("1003",dateStr);
        ajax.put("zbpm",zhxtZTjList==null?new ArrayList<ZhxtZTj>():zhxtZTjList);
        //获取二级数据
        //List<SysTjcode> sysTjcodeList = iLeaderSerivce.getTjcodeZzList();
        List<ZhxtZzData> zhxtZzDataList=new ArrayList<>();
        if(zhxtZTjList!=null){
            for (ZhxtZTj sysTjcode : zhxtZTjList) {
                ZhxtZzData zhxtZzData=new ZhxtZzData();
                zhxtZzData.setTjcode(sysTjcode.getTjcode());
                zhxtZzData.setTjname(sysTjcode.getTjname());
                //zhxtZzData.setUptjcode(sysTjcode.getUptjcode());
                zhxtZzData.setZhxtZItemsList(iZhxtService.getZhxtZzItems("1003",dateStr,sysTjcode.getTjcode()));
                zhxtZzDataList.add(zhxtZzData);
            }
        }
        ajax.put("zzdata",zhxtZzDataList);
        //获取二级平均数据
        //List<ZhxtZItems> zhxtZItemsListAvg=iZhxtService.getAvgItems("1003",dateStr);
        //ajax.put("avgdata",zhxtZItemsListAvg);
        //获取预警指标-红绿灯
        List<ZhxtYjData> zhxtYjDataList=iZhxtService.getTListyj("1003",dateStr);
        ajax.put("yjdata",zhxtYjDataList==null?new ArrayList<>():zhxtYjDataList);
        return ajax;
    }

    /**
     * 获取管理报表明细数据
     */
    @Log(title = "大屏-查看健康管理报表明细", businessType = BusinessType.OTHER)
    @PostMapping("/getGlReportMx")
    public AjaxResult getGlReportMx(String tjcode) {
        AjaxResult ajax = AjaxResult.success();
        String utime = iZhxtService.getLastTime();
        String dateStr = "";
        if(StringUtils.isNotEmpty(utime)){
            dateStr = utime.substring(0, 10);
        }
        List<ZhxtZItems> zhxtZItemsList=iZhxtService.getMItemsList("1003",dateStr,tjcode);
        ajax.put("data",zhxtZItemsList==null?new ArrayList<ZhxtZItems>():zhxtZItemsList);
        List<ZhxtItemsStep> zhxtItemsStepList=iZhxtService.getItemStep("1003",dateStr,tjcode);
        ajax.put("itemstep",zhxtItemsStepList==null?new ArrayList<ZhxtItemsStep>():zhxtItemsStepList);
        SysTjcode sysTjcode=iLeaderSerivce.getTjName(tjcode);
        ajax.put("tjname",sysTjcode==null?"":sysTjcode.getTjname());
        return ajax;
    }

    /**
     * 获取管理报表明细数据
     */
    @Log(title = "大屏-查看健康管理报表明细", businessType = BusinessType.OTHER)
    @PostMapping("/getJkglReportMx")
    public AjaxResult getJkglReportMx(String tjcode) {
        AjaxResult ajax = AjaxResult.success();
        String utime = iZhxtService.getLastTime();
        String dateStr = "";
        if(StringUtils.isNotEmpty(utime)){
            dateStr = utime.substring(0, 10);
        }
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        //TODO  如果dataStr为空待处理
        LocalDate dateqn = LocalDate.parse(dateStr, formatter).minusYears(1);
        String qndateStr = dateqn.format(formatter);
        List<ZhxtZItems> zhxtZItemsList=iZhxtService.getMItemsList("100310",dateStr,tjcode);
        ajax.put("data",zhxtZItemsList==null?new ArrayList<ZhxtZItems>():zhxtZItemsList);
        //获取去年数据
        List<ZhxtZItems> qnzhxtZItemsList=iZhxtService.getQnMItemsList("100310",dateStr,qndateStr,tjcode);
        ajax.put("qndata",qnzhxtZItemsList);
        SysTjcode sysTjcode=iLeaderSerivce.getTjName(tjcode);
        ajax.put("tjname",sysTjcode==null?"":sysTjcode.getTjname());
        return ajax;
    }

    /**
     * 获取投产报表数据
     */
    @Log(title = "大屏-查看投产报表", businessType = BusinessType.OTHER)
    @PostMapping("/getTcReport")
    public AjaxResult getTcReport(){
        AjaxResult ajax = AjaxResult.success();
        String utime=iZhxtService.getLastTime();
        String dateStr = "";
        if(StringUtils.isNotEmpty(utime)){
            dateStr = utime.substring(0, 10);
        }
        //获取报表一级数据
        List<ZhxtZItems> zhxtZItemsList=iZhxtService.getZhxtYItems("1004",dateStr);
        ajax.put("zbitems",zhxtZItemsList);

        //获取投产指标数据
        //排名
        List<ZhxtZTj> zhxtZTjList=iZhxtService.getZhxtZTj("1004",dateStr);
        ajax.put("zbpm",zhxtZTjList);
        //获取二级数据
        //List<SysTjcode> sysTjcodeList = iLeaderSerivce.getTjcodeZzList();
        List<ZhxtZzData> zhxtZzDataList=new ArrayList<>();
        if(zhxtZTjList!=null){
            for (ZhxtZTj sysTjcode : zhxtZTjList) {
                ZhxtZzData zhxtZzData=new ZhxtZzData();
                zhxtZzData.setTjcode(sysTjcode.getTjcode());
                zhxtZzData.setTjname(sysTjcode.getTjname());
                //zhxtZzData.setUptjcode(sysTjcode.getUptjcode());
                List<ZhxtZItems> zhxtZzItems = iZhxtService.getZhxtZzItems("1004", dateStr, sysTjcode.getTjcode());
                zhxtZzData.setZhxtZItemsList(zhxtZzItems);
                zhxtZzDataList.add(zhxtZzData);
            }
        }

        ajax.put("zzdata",zhxtZzDataList);
        //获取二级平均数据
        //List<ZhxtZItems> zhxtZItemsListAvg=iZhxtService.getAvgItems("1004",dateStr);
        //ajax.put("avgdata",zhxtZItemsListAvg);
        //获取预警指标-红绿灯
        List<ZhxtYjData> zhxtYjDataList=iZhxtService.getTListyj("1004",dateStr);
        ajax.put("yjdata",zhxtYjDataList==null?new ArrayList<>():zhxtYjDataList);
        return ajax;
    }

    /**
     * 获取投产报表明细数据
     */
    @Log(title = "大屏-查看投产报表明细", businessType = BusinessType.OTHER)
    @PostMapping("/getTcReportMx")
    public AjaxResult getTcReportMx(String tjcode) {
        AjaxResult ajax = AjaxResult.success();
        String utime = iZhxtService.getLastTime();
        String dateStr="";
        if(StringUtils.isNotEmpty(utime)){
             dateStr = utime.substring(0, 10);
        }
        List<ZhxtZItems> zhxtZItemsList=iZhxtService.getMItemsList("1004",dateStr,tjcode);
        if(zhxtZItemsList!=null&& !zhxtZItemsList.isEmpty()){
            ajax.put("data",zhxtZItemsList);
        }
        SysTjcode sysTjcode=iLeaderSerivce.getTjName(tjcode);

        ajax.put("tjname",sysTjcode==null?"":sysTjcode.getTjname());
        return ajax;
    }

    /**
     * 获取经营成本报表
     */
    @Log(title = "大屏-查看成本报表", businessType = BusinessType.OTHER)
    @PostMapping("/getCbReport")
    public AjaxResult getCbReport(){
        AjaxResult ajax=AjaxResult.success();
        String utime=iZhxtService.getLastTime();
        String dateStr="";
        if(StringUtils.isNotEmpty(utime)){
            dateStr = utime.substring(0, 10);
        }
        //获取报表一级数据
        List<ZhxtZItems> zhxtZItemsList=iZhxtService.getZhxtYItems("1005",dateStr);
        if(zhxtZItemsList!=null&& !zhxtZItemsList.isEmpty()){
            ajax.put("zbitems",zhxtZItemsList);
        }
        //地图指标排名
        List<ZhxtZTj> zhxtZTjList=iZhxtService.getZhxtZTj("1005",dateStr);
        if(zhxtZItemsList!=null&&!zhxtZItemsList.isEmpty()){
            ajax.put("zbpm",zhxtZTjList);
        }
        String yearStr="";
        if(StringUtils.isNotEmpty(dateStr)){
            yearStr=dateStr.substring(0,4);
        }
        String[] yearmonList = {"01","02","03","04","05","06","07","08","09","10","11","12"};
        List<ZhxtMonthList> zhxtMonthListListrl=new ArrayList<>();
        for(String str:yearmonList){
            ZhxtMonthList zhxtMonthList=new ZhxtMonthList();
            zhxtMonthList.setYearmon(str);
            zhxtMonthList.setZhxtMonthItems(new ArrayList<>());
            zhxtMonthListListrl.add(zhxtMonthList);
        }
        //核心人力
        List<ZhxtMonthItem> zhxtMonthItemList1=iZhxtService.getLastdayValue(yearStr,"202301091602007");
        //目标核心人力
        List<ZhxtMonthItem> zhxtMonthItemList2=iZhxtService.getLastdayValue(yearStr,"202302210954011");
        for (ZhxtMonthList zhxtMonthList:zhxtMonthListListrl){
            for (ZhxtMonthItem zhxtMonthItem:zhxtMonthItemList1){
                if(zhxtMonthItem.getYearmon().equals(zhxtMonthList.getYearmon())){
                    zhxtMonthItem.setItemname("核心人力");
                    zhxtMonthList.getZhxtMonthItems().add(zhxtMonthItem);
                    break;
                }
            }
            for (ZhxtMonthItem zhxtMonthItem:zhxtMonthItemList2){
                if(zhxtMonthItem.getYearmon().equals(zhxtMonthList.getYearmon())){
                    zhxtMonthItem.setItemname("目标核心人力");
                    zhxtMonthList.getZhxtMonthItems().add(zhxtMonthItem);
                    break;
                }
            }
        }
        ajax.put("rldata",zhxtMonthListListrl);

        List<ZhxtMonthList> zhxtMonthListListrj=new ArrayList<>();
        for(String str:yearmonList){
            ZhxtMonthList zhxtMonthList=new ZhxtMonthList();
            zhxtMonthList.setYearmon(str);
            zhxtMonthList.setZhxtMonthItems(new ArrayList<>());
            zhxtMonthListListrj.add(zhxtMonthList);
        }
        //人均总成本当年
        List<ZhxtMonthItem> zhxtMonthItemList3=iZhxtService.getLastdayValue(yearStr,"202302210954013");
        //人均总成本前一年
        String qyearStr=Convert.toStr(Convert.toInt(yearStr)-1);
        List<ZhxtMonthItem> zhxtMonthItemList4=iZhxtService.getLastdayValue(qyearStr,"202302210954013");
        for (ZhxtMonthList zhxtMonthList:zhxtMonthListListrj){
            for (ZhxtMonthItem zhxtMonthItem:zhxtMonthItemList3){
                if(zhxtMonthItem.getYearmon().equals(zhxtMonthList.getYearmon())){
                    zhxtMonthItem.setItemname("人均总成本当年");
                    zhxtMonthList.getZhxtMonthItems().add(zhxtMonthItem);
                    break;
                }
            }
            for (ZhxtMonthItem zhxtMonthItem:zhxtMonthItemList4){
                if(zhxtMonthItem.getYearmon().equals(zhxtMonthList.getYearmon())){
                    zhxtMonthItem.setItemname("人均总成本前一年");
                    zhxtMonthList.getZhxtMonthItems().add(zhxtMonthItem);
                    break;
                }
            }
        }
        ajax.put("rjdata",zhxtMonthListListrj);
        //象限图
        List<ZhxtXxt> zhxtXxtListX=iZhxtService.getTListOne("1005",dateStr,"202302210954010");
        List<ZhxtXxt> zhxtXxtListY=iZhxtService.getTListOne("1005",dateStr,"202302210954012");
        if(zhxtXxtListX!=null && zhxtXxtListY!=null){
            for (ZhxtXxt zhxtXxtx:zhxtXxtListX){
                zhxtXxtx.setIntx((zhxtXxtx.getIntx()-1)*100);
                for (ZhxtXxt zhxtXxty:zhxtXxtListY){
                    if(zhxtXxtx.getTjcode().equals(zhxtXxty.getTjcode())){
                        zhxtXxtx.setInty(zhxtXxty.getIntx());
                        break;
                    }
                }
            }
        }
        ZhxtXxt zhxtXxtn=new ZhxtXxt();
        zhxtXxtn.setTjcode("00");
        zhxtXxtn.setTjname("原点");
        zhxtXxtn.setIntx(100);
        zhxtXxtn.setInty(0);
        zhxtXxtListX.add(zhxtXxtn);
        ajax.put("xxt",zhxtXxtListX);

        return ajax;
    }

    /**
     * 获取经营成本报表明细
     */
    @Log(title = "大屏-查看成本报表明细", businessType = BusinessType.OTHER)
    @PostMapping("/getCbReportMx")
    public AjaxResult getCbReportMx(String tjcode){
        AjaxResult ajax=AjaxResult.success();
        String utime=iZhxtService.getLastTime();
        String dateStr="";
        if(StringUtils.isNotEmpty(utime)){
            dateStr = utime.substring(0, 10);
        }
        //获取四级机构列表
        List<SysTjcode> sysTjcodeList = iLeaderSerivce.getTjcodeList(tjcode);

        List<ZhxtZzData> zhxtZzData=new ArrayList<>();
        if(sysTjcodeList!=null){
            for(SysTjcode sysTjcode:sysTjcodeList){
                ZhxtZzData zzData=new ZhxtZzData();
                zzData.setTjcode(sysTjcode.getTjcode());
                zzData.setTjname(sysTjcode.getTjname());
                zzData.setUptjcode(sysTjcode.getUptjcode());
                List<ZhxtZItems> zhxtZItemsList=iZhxtService.getMItemsList("1005",dateStr,sysTjcode.getTjcode());
                zzData.setZhxtZItemsList(zhxtZItemsList==null?new ArrayList<>():zhxtZItemsList);
                zhxtZzData.add(zzData);
            }
        }
        ajax.put("data",zhxtZzData);

        SysTjcode sysTjcode=iLeaderSerivce.getTjName(tjcode);
        ajax.put("tjname",sysTjcode==null?"":sysTjcode.getTjname());

        return ajax;
    }

    /**
     * 获取经营成本报表--新报表
     */
    @Log(title = "大屏-查看新成本报表", businessType = BusinessType.OTHER)
    @PostMapping("/getJycbReport")
    public AjaxResult getJycbReport(String tjcode){
        AjaxResult ajax=AjaxResult.success();
        String utime=iZhxtService.getLastTime();
        String dateStr="";
        if(StringUtils.isNotEmpty(utime)){
            dateStr = utime.substring(0, 10);
        }
        //获取报表一级数据
        List<ZhxtZItems> zhxtZItemsList=iZhxtService.getJycbReport(tjcode,dateStr);
        ajax.put("zbitems",zhxtZItemsList==null?new ArrayList<>():zhxtZItemsList);
        String yearStr="";
        if(StringUtils.isNotEmpty(dateStr)){
            yearStr  =dateStr.substring(0,4);
        }
        //获取特殊指标
        List<ZhxtZItems> zhxtZItems=iZhxtService.getZbItemsList("1006","T");
        if(zhxtZItems!=null){
            for (ZhxtZItems zhxtZItems1:zhxtZItems){
                //查询指标当年所有值
                List<ZhxtMonthItem> zhxtMonthItemList=iZhxtService.getLastdayValueTjcode(tjcode,yearStr,zhxtZItems1.getItemcode());
                ajax.put(zhxtZItems1.getItemcode(),zhxtMonthItemList);
            }
        }
        return ajax;
    }

    /**
     * 获取经营成本报表明细-新报表
     */
    @Log(title = "大屏-查看新成本报表明细", businessType = BusinessType.OTHER)
    @PostMapping("/getJycbReportMx")
    public AjaxResult getJycbReportMx(String tjcode){
        AjaxResult ajax = AjaxResult.success();
        String utime = iZhxtService.getLastTime();
        String dateStr="";
        if(StringUtils.isNotEmpty(utime)){
            dateStr = utime.substring(0, 10);
        }
        List<ZhxtMonthList> zhxtMonthList=iZhxtService.getMItemsListJy("1006",dateStr,tjcode);
        ajax.put("data",zhxtMonthList==null?new ArrayList<>():zhxtMonthList);
        SysTjcode sysTjcode=iLeaderSerivce.getTjName(tjcode);
        ajax.put("tjname",sysTjcode==null?"":sysTjcode.getTjname());
        return ajax;
    }
}
